package com.example.xx.dao;


import com.example.xx.pojo.TPermission;
import com.example.xx.pojo.TRole;
import com.example.xx.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserDao {
    // 注册
    @Insert("insert into user(username,password) values(#{username},#{password})")
    int zhuce(User user);
    // 登录 查询
    @Select("select * from user where username=#{username}")
    User login(User user);
    // 编辑查询
    @Select("select * from user where id=#{id}")
    User cha(Integer id);

    // 修改个人信息
    @Update("update user set nickname=#{nickname},email=#{email} where id=#{id}")
    int xiugai(User user);
    // 上传头像
    @Update("update user set user_pic=#{user_pic} where id=#{id}")
    int shangchaun(User user);
    // 修改密码
    @Update("update user set password=#{password} where id=#{id}")
    int xiugaimima(User user);
    @Select("select * from t_role where id in (select role_id from t_user_role where user_id=#{id})")
    List<TRole> getRole(Integer id);
    @Select("select keyword from t_permission where id in (select permission_id from t_role_permission where role_id IN (select role_id from t_user_role where user_Id =#{id}))")
    List<TPermission> getPermission(Integer id);
}
